<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <h:form>
            <p:panel id="panelPrint" styleClass="noBorder summeryBorder">
                <h:panelGrid columns="5" styleClass="noPrintButton">
                    <h:outputLabel value="From Date"/>
                    <h:outputLabel value="To Date"/>
                    <h:outputLabel value="Department"/>
                    <h:outputLabel/> <h:outputLabel/>
                    <p:calendar value="#{pharmacySaleReport.fromDate}" navigator="true" pattern="dd MMMM yyyy hh:mm a"  >

                    </p:calendar>
                    <p:calendar value="#{pharmacySaleReport.toDate}" navigator="true" pattern="dd MMMM yyyy hh:mm a" >

                    </p:calendar>
                    <p:autoComplete styleClass="noPrintButton"  value="#{pharmacySaleReport.department}"  style="text-align: left; margin: 5px; padding: 5px;"  completeMethod="#{departmentController.completeDept}" var="dept" itemValue="#{dept}" itemLabel="#{dept.name}" forceSelection="true" rendered="true" requiredMessage="You must select a department" >
                    </p:autoComplete>
                    <p:commandButton ajax="false" value="Process" action="#{pharmacySaleReport.createSalePaymentMethod()}"/>
                    <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" >
                        <p:printer target="panelPrint" />
                    </p:commandButton>

                </h:panelGrid>

                <h:panelGrid styleClass="printBlock" columns="2">
                    <h:outputLabel value="#{pharmacySaleReport.department.name}"/>
                    <h:outputLabel value=" DEPARTMENT SALE REPORT SUMMERY"/>                   
                    <h:outputLabel value="From Date :  "/>
                    <h:outputLabel value="#{pharmacySaleReport.fromDate}"  >
                        <f:convertDateTime pattern="dd MMMM yyyy" />
                    </h:outputLabel>
                    <h:outputLabel value="To Date"/>
                    <h:outputLabel value="#{pharmacySaleReport.toDate}"  >
                        <f:convertDateTime pattern="dd MMMM yyyy" />
                    </h:outputLabel>                       
                </h:panelGrid>

                <p:dataTable value="#{pharmacySaleReport.billedPaymentSummery.bills}" var="i">
                    <f:facet name="header">                        
                        <h:outputLabel value="BILLED"/>
                    </f:facet>
                    <p:column headerText="Date">
                        #{i.string}
                    </p:column>
                    <p:column headerText="CASH" style="text-align: right;">
                        <h:outputLabel value="#{i.value1}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="CREDIT" style="text-align: right;">
                        <h:outputLabel value="#{i.value2}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="CARD" style="text-align: right;">
                        <h:outputLabel value="#{i.value3}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="TOTAL" style="text-align: right;">
                        <h:outputLabel value="#{i.value4}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:columnGroup type="footer">
                        <p:row>
                            <p:column footerText="Total  " colspan="1" />
                            <p:column footerText="#{pharmacySaleReport.billedPaymentSummery.cashTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.billedPaymentSummery.cashTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.billedPaymentSummery.creditTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.billedPaymentSummery.creditTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.billedPaymentSummery.cardTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.billedPaymentSummery.cardTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.billedPaymentSummery.cashTotal+pharmacySaleReport.billedPaymentSummery.creditTotal+pharmacySaleReport.billedPaymentSummery.cardTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.billedPaymentSummery.cashTotal+pharmacySaleReport.billedPaymentSummery.creditTotal+pharmacySaleReport.billedPaymentSummery.cardTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                        </p:row>
                    </p:columnGroup>
                </p:dataTable>


                <p:dataTable value="#{pharmacySaleReport.cancelledPaymentSummery.bills}" var="i">
                    <f:facet name="header">                        
                        <h:outputLabel value="CANCELLED"/>
                    </f:facet>
                    <p:column headerText="Date">
                        #{i.string}
                    </p:column>
                    <p:column headerText="CASH" style="text-align: right;">
                        <h:outputLabel value="#{i.value1}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="CREDIT" style="text-align: right;">
                        <h:outputLabel value="#{i.value2}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="CARD" style="text-align: right;">
                        <h:outputLabel value="#{i.value3}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="TOTAL" style="text-align: right;">
                        <h:outputLabel value="#{i.value4}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:columnGroup type="footer">
                        <p:row>
                            <p:column footerText="Total  " colspan="1" />
                            <p:column footerText="#{pharmacySaleReport.cancelledPaymentSummery.cashTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.cancelledPaymentSummery.cashTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.cancelledPaymentSummery.creditTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.cancelledPaymentSummery.creditTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.cancelledPaymentSummery.cardTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.cancelledPaymentSummery.cardTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.cancelledPaymentSummery.cashTotal+pharmacySaleReport.cancelledPaymentSummery.creditTotal+pharmacySaleReport.cancelledPaymentSummery.cardTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.cancelledPaymentSummery.cashTotal+pharmacySaleReport.cancelledPaymentSummery.creditTotal+pharmacySaleReport.cancelledPaymentSummery.cardTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                        </p:row>
                    </p:columnGroup>
                </p:dataTable>

                <p:dataTable value="#{pharmacySaleReport.refundedPaymentSummery.bills}" var="i">
                    <f:facet name="header">                        
                        <h:outputLabel value="REFUNDED"/>
                    </f:facet>
                    <p:column headerText="Date">
                        #{i.string}
                    </p:column>
                    <p:column headerText="CASH" style="text-align: right;">
                        <h:outputLabel value="#{i.value1}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="CREDIT" style="text-align: right;">
                        <h:outputLabel value="#{i.value2}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="CARD" style="text-align: right;">
                        <h:outputLabel value="#{i.value3}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="TOTAL" style="text-align: right;">
                        <h:outputLabel value="#{i.value4}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:columnGroup type="footer">
                        <p:row>
                            <p:column footerText="Total  " colspan="1" />
                            <p:column footerText="#{pharmacySaleReport.refundedPaymentSummery.cashTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.refundedPaymentSummery.cashTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.refundedPaymentSummery.creditTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.refundedPaymentSummery.creditTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.refundedPaymentSummery.cardTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.refundedPaymentSummery.cardTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{pharmacySaleReport.refundedPaymentSummery.cashTotal+pharmacySaleReport.refundedPaymentSummery.creditTotal+pharmacySaleReport.refundedPaymentSummery.cardTotal}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{pharmacySaleReport.refundedPaymentSummery.cashTotal+pharmacySaleReport.refundedPaymentSummery.creditTotal+pharmacySaleReport.refundedPaymentSummery.cardTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                        </p:row>
                    </p:columnGroup>
                </p:dataTable>

                <p:spacer height="30"/>

                <h:panelGrid columns="2" style="min-width: 100%;">
                    <h:outputLabel value="Net Cash"/>
                    <h:outputLabel value="#{pharmacySaleReport.grantCashTotal}">
                        <f:convertNumber pattern="#,##0.00" />
                    </h:outputLabel>
                    <h:outputLabel value="Net Credit"/>
                    <h:outputLabel value="#{pharmacySaleReport.grantCreditTotal}" >
                        <f:convertNumber pattern="#,##0.00" />
                    </h:outputLabel>
                    <h:outputLabel value="Net Card"/>
                    <h:outputLabel value="#{pharmacySaleReport.grantCardTotal}">
                        <f:convertNumber pattern="#,##0.00" />
                    </h:outputLabel>
                </h:panelGrid>



            </p:panel>         


        </h:form>

    </ui:define>



</ui:composition>
